package com.zzl.bonds.ticket.dto.credit;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.zzl.apidoc.annotation.ApidocModel;
import com.zzl.apidoc.annotation.ApidocModelProperty;
import com.zzl.bonds.ticket.constant.type.QuotaTypeEnum;
import com.zzl.bonds.ticket.dto.KeyValue;
import com.zzl.bonds.ticket.entity.EnterpriseCreditDataEntity;
import com.zzl.general.common.utils.DoubleSerialize;
import lombok.Data;

import java.util.Date;
import java.util.List;

/**
 * @author : spp
 * @date : 2022/3/1 13:19
 */
@Data
@ApidocModel
public class CoreEnterpriseCreditPage {

    @ApidocModelProperty(description = "主键 ")
    private String id;
    @ApidocModelProperty(description = "额度编号")
    private String creditNo;
    @ApidocModelProperty(description = "企业id，即集团的企业id")
    private String enterpriseId;
    @ApidocModelProperty(description = "授信主体")
    private String enterpriseName;
    @ApidocModelProperty(description = "金融机构id")
    private Integer financeInstitutyId;
    @ApidocModelProperty(description = "金融机构名称")
    private String financeInstitutyName;

    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "总金额")
    private Double creditAllAmount;

    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "剩余金额")
    private Double creditSurplusAmount;

    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "可用金额")
    private Double creditAvailableAmount;

    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "冻结额度 ")
    private Double creditFrozenAmount;

    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "冻结额度/平台操作的锁定额度 ")
    private Double creditLockAmount;

    @JsonSerialize(using = DoubleSerialize.class)
    @ApidocModelProperty(description = "已用额度")
    private Double creditUsedAmount;

    private Integer creditType;
    @ApidocModelProperty(description = "额度类型，1 集团授信 2 独立授信")
    private String creditTypeStr;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApidocModelProperty(description = "生效日期", validate = "yyyy-MM-dd")
    private Date effectiveDate;
    @JsonFormat(pattern = "yyyy-MM-dd")
    @ApidocModelProperty(description = "失效日期", validate = "yyyy-MM-dd")
    private Date expiryDate;

    private Integer creditStatus;

    @ApidocModelProperty(description = "备注")
    private String remark;

    @ApidocModelProperty(description = "是否冻结 0 未冻结 1 已冻结 ")
    private Integer lockStatus;

    @ApidocModelProperty(description = "额度状态")
    private String creditStatusStr;
    @ApidocModelProperty(description = "操作按钮集合")
    private List<KeyValue> operateButton;

    @ApidocModelProperty(description = "附件资料")
    List<EnterpriseCreditDataEntity> datas;
    @ApidocModelProperty(description = "上链地址")
    private String chainAddress;
    @JsonIgnore
    private Integer quotaType;
    @ApidocModelProperty(description = "额度类型，1:凭证开立额度、3:承保额度")
    private String quotaTypeName;

    public String getQuotaTypeName() {
        if (null == quotaType) {
            return "";
        }
        return QuotaTypeEnum.getValue(quotaType);
    }
}
